package com.monkeyboy.service.rocketmqordermsg;

import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * @Author Gavin
 * @date 2020.08.23 13:02
 */
@Component
@RocketMQMessageListener(consumerGroup = "order_group", topic = "order_topic", selectorExpression = "*", consumeMode = ConsumeMode.ORDERLY)
public class OrderMessageConsumer implements RocketMQListener<MessageExt> {
    @Override
    public void onMessage(MessageExt msg) {
        System.out.println(msg.getReconsumeTimes());//消息重试的次数
        System.out.println("消费者消费队列id:" + msg.getQueueId() + "   消息内容：" + new String(msg.getBody()));
    }
}
